package gray.android.elem;

import java.math.BigDecimal;
import java.util.Date;

import gray.Frame;
import android.widget.TextView;
import android.content.Context;
import android.view.View;
import util.tool.SimpleCal;

public class TextElem extends TextView implements Frame<View>{

	private TextElem(Context context, final String text) {
		super(context);
		setText(text);
	}
	
	public static Frame<View> factory(Context context, final String text){
		return new TextElem(context, text);
	}
    
  public static Frame<View> factoryMoney(Context context, final BigDecimal num){
      return new TextElem(context, String.format("%.2f$", num));
  }

  public static Frame<View> factoryDate(Context context, final Date date){
      return new TextElem(context, SimpleCal.dateToSql(date));
  }

  public static Frame<View> factoryTime(Context context, final Date hour){
      return new TextElem(context, SimpleCal.timeToSql(hour));
  }

  public static Frame<View> factoryPercentage(Context context, final BigDecimal num){
      return new TextElem(context, String.format("%2.1f/%", num));  
  }

  public static Frame<View> factoryString(Context context, final String num){
      return new TextElem(context, String.format("%d", num));  
  }

	@Override
	public View container() {
		return this;
	}

	@Override
	public Boolean ready() {
		return true;
	}
}
